define(['jquery.min'],function($){
    // window.alert =
    $.alert = function(val){

        var op = {
            "type" : "alert",
            "timer" : 2000,
            "className" : {
                "type" : "",
                "flash" : "alertFlash"
            }
        };

        if(val.constructor === Object){
            $.extend(op,val);
        }else{
            op.val = val;
        }
        if(op.val.constructor !== String){
            op.val = op.val.toString();
        }
        if(!op.val || (op.val.constructor !== String  && op.val.constructor !== String))
            return "not value";

        var $alert = $("<div class='alertBox'>").addClass(op.className[op.type]),
            $text = $("<div class='alertText'>").html(op.val).appendTo($alert),
            $ok = $("<div class='alertBtn'>").html("确定").appendTo($alert),
            _mask;
        if(op.type == "flash"){
            _mask = new mask("mask_flash");
        }else{
            _mask = new mask();
        }
        _mask.show();

        function closeAlert(){
            $alert.remove();
            _mask.hide();
            delete _mask;
            op.callback && op.callback();
        }

        $ok.on("touchend",function(){
            $alert.on("webkitTransitionEnd",closeAlert).removeClass("alertShow");
        });

        $alert.appendTo("body");
        setTimeout(function(){
            $alert.addClass("alertShow");
            if(op.type && op.type == "flash"){
                setTimeout(closeAlert,op.timer);
            }
        });

    };
});